package com.cyl.manager.act.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;


import com.cyl.manager.act.domain.entity.FhMyai;
import com.cyl.manager.act.domain.convert.FhMyaiConvert;
import com.cyl.manager.act.domain.query.FhMyaiQuery;
import com.cyl.manager.act.domain.vo.FhMyaiVO;
import com.cyl.manager.act.service.FhMyaiService;

import com.ruoyi.common.utils.poi.ExcelUtil;
/**
 * ai管理Controller
 *
 * @author zcc
 * @date 2025-07-07
 */
@Api(description ="ai管理接口列表")
@RestController
@RequestMapping("/act/fhMyai")
public class FhMyaiController extends BaseController {
    @Autowired
    private FhMyaiService service;
    @Autowired
    private FhMyaiConvert convert;

    @ApiOperation("查询ai管理列表")
    @PreAuthorize("@ss.hasPermi('act:fhMyai:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<FhMyai>> list(@RequestBody FhMyaiQuery query, Pageable page) {
        List<FhMyai> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("导出ai管理列表")
    @PreAuthorize("@ss.hasPermi('act:fhMyai:export')")
    @Log(title = "ai管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public ResponseEntity<String> export(FhMyaiQuery query) {
        List<FhMyai> list = service.selectList(query, null);
        ExcelUtil<FhMyaiVO> util = new ExcelUtil<>(FhMyaiVO.class);
        return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "ai管理数据"));
    }

    @ApiOperation("获取ai管理详细信息")
    @PreAuthorize("@ss.hasPermi('act:fhMyai:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<FhMyai> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增ai管理")
    @PreAuthorize("@ss.hasPermi('act:fhMyai:add')")
    @Log(title = "ai管理", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody FhMyai fhMyai) {
        return ResponseEntity.ok(service.insert(fhMyai));
    }

    @ApiOperation("修改ai管理")
    @PreAuthorize("@ss.hasPermi('act:fhMyai:edit')")
    @Log(title = "ai管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody FhMyai fhMyai) {
        return ResponseEntity.ok(service.update(fhMyai));
    }

    @ApiOperation("删除ai管理")
    @PreAuthorize("@ss.hasPermi('act:fhMyai:remove')")
    @Log(title = "ai管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
